package com.caption.design.mixture;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class PayFactory {

    private static Map<String, Handler> handlerMap = new ConcurrentHashMap<>(32);

    public static Handler getHandler(String handlerName) {
        return handlerMap.get(handlerName);
    }

    //putIfAbsent 如果传入key对应的value已经存在，就返回存在的value，不进行替换。如果不存在，就添加key和value
    public static void register(String name, Handler handler) {
        if (name == null || handler == null) {
            return;
        }
        handlerMap.putIfAbsent("name", handler);
    }

}
